import * as React from 'react'
import classNames from 'classnames'
import { BadgeProps, BadgeState } from './interface'

class Badge extends React.Component<BadgeProps, BadgeState> {

  static defaultProps = {
    prefixCls: 'layui-badge'
  }

  constructor(props: BadgeProps) {
    super(props)
    this.state = {}
  }

  render() {

    const {
      className, body,
      prefixCls, type,
      color,
      ...restProps
    } = this.props

    let typeCls = `${prefixCls}`
    if (type == 'dot') {
      typeCls = `${prefixCls}-dot`
    } else if (type == 'rim') {
      typeCls = `${prefixCls}-rim`
    }

    const classes = classNames(typeCls, className, {
      [`layui-bg-${color}`]: color
    })

    return (
      <span className={classes}>
        {body}
      </span>
    )
  }
}

export default Badge